package com.trt.workflow;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.ProcessDefinition;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * @author 谭仁涛
 * @description 流程定义
 * @date 2022/2/19 14:22
 */
@SpringBootTest
public class Part2_ProcessDefinition {

    @Autowired
    private RepositoryService repositoryService;

    // 查询流程定义
    @Test
    public void getDefinitions() {
        List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().list();
        for (ProcessDefinition pd : list) {
            System.out.println("--------流程定义---------");
            System.out.println("Name : " + pd.getName());
            System.out.println("Key : " + pd.getKey());
            System.out.println("ResourceName : " + pd.getResourceName());
            System.out.println("DeploymentId : " + pd.getDeploymentId());
            System.out.println("Version : " + pd.getVersion());
        }
    }

    // 删除流程定义
    @Test
    public void delDefinition() {
        String pdID = "ba6f4363-9139-11ec-b66b-00ff6fa8c6c1";
        repositoryService.deleteDeployment(pdID, true);
        System.out.println("删除流程定义成功");
    }
}
